﻿@{
    ViewData["Title"] = "添加角色";
    Layout = "_Edit";
}

<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-add">
        <input type="hidden" class="input-text" value="@Model.ID" placeholder="" id="id" name="id">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>角色编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Code" placeholder="" id="code" name="code">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>角色名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.FullName" placeholder="" id="fullName" name="fullName">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">角色备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.Description" placeholder="" id="des" name="des">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="button" class="btn btn-success radius" onclick="operateFunction();" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
            </div>
        </div>
    </form>
</article>

@section javascript {
<script type="text/javascript">

        function operateFunction(){
        var code=$("#code").val();
        if(code==null||code=="")
        {
           popupAlert('角色编号不能为空',2,function(data){layer.close(data);});
          return;
        }
        var fullName=$("#fullName").val();
        if(fullName==null||fullName=="")
        {
           popupAlert('角色名称不能为空',2,function(data){layer.close(data);});
          return;
        }
       SubmitFormForAjax("/admin/operaterole", $("#form-add").serialize(), function (data) {
           if (data.result) {
                   popupAlert('提交成功',1,function(){closePageLayer(true);});
           }else{
               popupAlert(data.message,2,function(data){layer.close(data);});
           }
       },true);
    }
</script>
}

